package com.mfl.mapper;

import com.github.pagehelper.Page;
import com.mfl.pojo.dto.CourseCategoryDTO;
import com.mfl.pojo.dto.CourseCategoryPageQueryDTO;
import com.mfl.pojo.entity.CourseCategory;
import com.mfl.pojo.vo.CourseCategoryPageQueryVO;
import com.mfl.pojo.vo.CourseCategoryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CourseCategoryMapper {
    /**
     * 根据课程分类名称查询
     * @param courseCategoryName
     * @return
     */
    @Select("select * from course_category where course_category_name = #{courseCategoryName}")
    CourseCategory getByCourseCategoryName(String courseCategoryName);

    /**
     * 添加课程分类
     * @param courseCategory
     */
    void insert(CourseCategory courseCategory);

    /**
     * 分页查询课程分类
     * @param courseCategoryPageQueryDTO
     * @return
     */
    Page<CourseCategoryPageQueryVO> pageQuery( CourseCategoryPageQueryDTO courseCategoryPageQueryDTO);

    /**
     * 批量删除课程分类
     * @param ids
     */
    void deleteByIds(List<Integer> ids);

    /**
     * 修改课程分类状态
     * @param status
     * @param id
     */
    @Update("update course_category set status = #{status} where id = #{id}")
    void updateStatus(Integer status, Integer id);

    @Select("select * from course_category where id = #{id}")
    CourseCategory getByCourseCategoryId(int id);

    /**
     * 修改课程分类
     * @param courseCategory
     */
    void update(CourseCategory courseCategory);

    /**
     * 查询所有启用的课程分类
     * @return
     */
    @Select("select * from course_category where status = 1")
    List<CourseCategoryVO> selectAll();
}
